package com.rear.inter;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.rear.entity.MessageEntity;
import com.rear.entity.MessageRecordEntity;
import com.rear.entity.MessageTypeEntity;
import com.rear.entity.XatLogEntity;
import com.rear.inter.base.BaseAction;
import com.rear.inter.base.JsonVo;
import com.rear.service.AppMessageService;
import com.rear.service.MessageRecordService;
import com.rear.service.MessageService;
import com.rear.service.MessageTypeService;
import com.rear.service.XatLogService;
import com.rear.utils.DateUtil;
import com.rear.utils.HttpRequest;
import com.rear.utils.JsonUtil;
/**
 * 
* 
* 类名称：ComInterface 
* 类描述： 
* 创建人：October
* 修改备注： 
* @version 1.0
 */
@RequestMapping("/interface/com")
@Controller
public class ComInterface extends BaseAction{
	
	@Autowired
	private XatLogService xatLogService;
	
	@Autowired
	private MessageService messageService;
	
	@Autowired
	private MessageTypeService messageTypeService;
	
	@Autowired
	private MessageRecordService messageRecordService;
	
	@Autowired
	private AppMessageService appMessageService;
	
	@RequestMapping(value = "/addXatLog.json", method = RequestMethod.GET)
	public  void addXatLog(
			//渠道来源：学安通/学安成长/...
			String qdly,
			//操作类型：浏览/点击/...
			String czlx,
			//操作主题：XX页面/XX按钮/XX...
			String czzt,
			//操作链接
			String linkurl,
			String mark,
			String exp1,
			String exp2,
			String exp3,
			String exp4,
			String exp5,
			HttpServletResponse response,
			HttpServletRequest request) {
		JsonVo<String> json = new JsonVo<String>();
		try {
			XatLogEntity xatLog=new XatLogEntity();
			xatLog.setQdly(qdly);
			xatLog.setCzlx(czlx);
			xatLog.setCzzt(czzt);
			xatLog.setLinkurl(linkurl);
			xatLog.setMark(mark);
			xatLog.setExp1(exp1);
			xatLog.setExp2(exp2);
			xatLog.setExp3(exp3);
			xatLog.setExp4(exp4);
			xatLog.setExp5(exp5);
			xatLogService.save(xatLog);
			json.setResult(true);
		} catch (Exception e) {
			e.printStackTrace();
			json.setMsg("添加日志出错！");
			json.setResult(false);
		}
		ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
		return;
	}
	
	/**
	 * 未读消息数量
	 */
	@RequestMapping(value = "/number/unread/messages.json", method = RequestMethod.GET)
	public  void numberUnreadMessages(
			@RequestParam String userUniqueID,//用户唯一标识
			@RequestParam String appID,//应用id
			@RequestParam long createTime,//用户创建时间
			String sign,
			HttpServletResponse response,
			HttpServletRequest request) {
		JsonVo<Map<String, Object>> json = new JsonVo<Map<String, Object>>();
		try {
			String id=appMessageService.uniqueIDToID(appID);
			if(ObjectUtils.isEmpty(id)){
				json.setMsg("应用ID出错！");
				json.setResult(false);
				ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
				return;
			}else{
				if(informationCheck(sign, id, userUniqueID)){
					json.setMsg("参数不合法！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				
				Map<String, Object> map = new HashMap<>();
				String unreadCount=this.unreadCount(
						id, 
						userUniqueID,
						null,
						DateUtil.dateLongToString(createTime, "yyyy-MM-dd HH:mm:ss"));
				map.put("unreadCount", unreadCount);
				if("0".equals(unreadCount)){
					map.put("existence", false);
				}else{
					map.put("existence", true);
				}
				json.setT(map);
				json.setResult(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
			json.setMsg("查询出错！");
			json.setResult(false);
		}
		ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
		return;
	}
	
	/**
	 * 消息中心
	 */
	@RequestMapping(value = "/message/center.json", method = RequestMethod.GET)
	public  void messageCenter(
			@RequestParam String userUniqueID,//用户唯一标识
			@RequestParam String appID,//应用id
			@RequestParam long createTime,//用户创建时间 
			@RequestParam String sign,
			HttpServletResponse response,
			HttpServletRequest request) {
		JsonVo<Map<String, Object>> json = new JsonVo<Map<String, Object>>();
		try {
			List<MessageCenterClass> MessageCenterClassList=new ArrayList<MessageCenterClass>();
			String id=appMessageService.uniqueIDToID(appID);
			if(ObjectUtils.isEmpty(id)){
				json.setMsg("应用ID出错！");
				json.setResult(false);
				ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
				return;
			}else{
				if(informationCheck(sign, id, userUniqueID)){
					json.setMsg("参数不合法！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				
				List<MessageTypeEntity> messageTypeList=this.messageTypeList(id);
				for (MessageTypeEntity  messageType: messageTypeList){
					MessageCenterClass messageCenterClass=new MessageCenterClass();
					String mType= messageType.getMessageTypeName()+","+messageType.getDisplayMode();
					MessageEntity messageEntity=
							this.messageService.getShowMessage(
									this.findMap(
											id, 
											userUniqueID, 
											mType,
											DateUtil.dateLongToString(createTime, "yyyy-MM-dd HH:mm:ss")));
					if(!ObjectUtils.isEmpty(messageEntity)){
						messageCenterClass.setIconUrl(messageType.getIconUrl());
						messageCenterClass.setId(messageType.getId().toString());
						messageCenterClass.setMessageHeader(messageEntity.getMessageHeader());
						messageCenterClass.setMessageProfile(messageEntity.getMessageProfile());
						messageCenterClass.setMessageTag(messageEntity.getMessageTag());
						messageCenterClass.setMessageTypeName(messageType.getMessageTypeName());
						messageCenterClass.setTypeUrl("");
						messageCenterClass.setUnreadCount(
								this.unreadCount(
										id, 
										userUniqueID ,
										mType,
										DateUtil.dateLongToString(createTime, "yyyy-MM-dd HH:mm:ss")));
						MessageCenterClassList.add(messageCenterClass);
					}
				}
				Map<String, Object> map = new HashMap<>();
				map.put("messageList", MessageCenterClassList);
				json.setT(map);
				json.setResult(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
			json.setMsg("查询出错！");
			json.setResult(false);
		}
		ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
		return;
	}
	
	/**
	 * 具体类型 消息列表
	 */
	@RequestMapping(value = "/message/list.json", method = RequestMethod.GET)
	public  void messageList(
			@RequestParam String userUniqueID,//用户唯一标识
			@RequestParam String appID,//应用id
			@RequestParam Integer mType,//消息类型
			@RequestParam long createTime,//用户创建时间 
			@RequestParam String sign,
			Integer page, 
			Integer limit,
			HttpServletResponse response,
			HttpServletRequest request) {
		JsonVo<Map<String, Object>> json = new JsonVo<Map<String, Object>>();
		try {
			String id=appMessageService.uniqueIDToID(appID);
			if(ObjectUtils.isEmpty(id)){
				json.setMsg("应用ID出错！");
				json.setResult(false);
				ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
				return;
			}else{
				if(informationCheck(sign, id, userUniqueID)){
					json.setMsg("参数不合法！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				MessageTypeEntity messageType=messageTypeService.queryObject(mType);
				String mTypeName= messageType.getMessageTypeName()+","+messageType.getDisplayMode();
				Map<String, Object> queryMap=this.findMap(
								id, 
								userUniqueID, 
								mTypeName,
								DateUtil.dateLongToString(createTime, "yyyy-MM-dd HH:mm:ss"));
				queryMap.put("offset", (page - 1) * limit);
				queryMap.put("limit", limit);
				List<MessageEntity> messageList=this.messageService.messageShowList(queryMap);
				int count =messageService.messageCount(queryMap);
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("messageList", messageList);
				map.put("count", count);
				
				json.setT(map);
				json.setResult(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
			json.setMsg("查询出错！");
			json.setResult(false);
		}
		ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
		return;
	}
	/**消息阅读接口*/
	@RequestMapping(value = "/message/read.json", method = RequestMethod.GET)
	public  void messageRead(
			@RequestParam String userUniqueID,//用户唯一标识
			@RequestParam String appID,//应用id
			@RequestParam String messageID,//消息id
			@RequestParam String sign,
			HttpServletResponse response,
			HttpServletRequest request) {
		JsonVo<Map<String, Object>> json = new JsonVo<Map<String, Object>>();
		try {

			String id=appMessageService.uniqueIDToID(appID);
			if(ObjectUtils.isEmpty(id)){
				json.setMsg("应用ID出错！");
				json.setResult(false);
				ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
				return;
			}else{
				if(informationCheck(sign, id, userUniqueID)){
					json.setMsg("参数不合法！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				
				Map<String, Object> map = new HashMap<>();
				map.put("receiveMessageObject", userUniqueID);
				map.put("messageId", messageID);
				map.put("channelid", appID);
				List<MessageRecordEntity> messageRecordList = messageRecordService.queryList(map);
				if(messageRecordList.size()==0){
					MessageRecordEntity messageRecord=new MessageRecordEntity();
					messageRecord.setChannelid(appID);
					messageRecord.setMessageId(messageID);
					messageRecord.setReceiveMessageObject(userUniqueID);
					messageRecordService.save(messageRecord);
				}
				json.setResult(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
			json.setMsg("更新出错！");
			json.setResult(false);
		}
		ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
		return;
	}
	
	
	/**中转消息*/
	@RequestMapping(value = "/transit/message.json", method = RequestMethod.POST)
	public  void transitMessage(
			Integer messageType, //消息类型
			String messageTag, //消息标签
			String messageHeader, //消息标题
			String messageProfile, //消息简介
			String messageContent, //消息内容
			String messageCoverUrl, //消息封面url
			String displayMode, //展现方式
			String messageLink, //消息链接
			String receiveMessageObjectType, //接收消息对象类型
			String receiveMessageObjects, //接收消息对象
			Integer ifPush, //是否启用第三方推送
			Integer whetherPush, //推送方式
			long pushTime, //推送时间
			String channelid, //渠道标识
			long displayTime, //展示时间
			long timeExpired, //过期时间
			String sign,
			HttpServletResponse response,
			HttpServletRequest request) {
		JsonVo<Map<String, Object>> json = new JsonVo<Map<String, Object>>();
		try {
			if(ObjectUtils.isEmpty(channelid)){
				json.setMsg("appID不能为空！");
				json.setResult(false);
				ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
				return;
			}
			String id=appMessageService.uniqueIDToID(channelid);
			if(ObjectUtils.isEmpty(id)){
				json.setMsg("应用ID出错！");
				json.setResult(false);
				ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
				return;
			}else{
				
				if(ObjectUtils.isEmpty(sign)){
					json.setMsg("sign不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				if(informationCheck(sign, id, messageHeader)){
					json.setMsg("参数不合法！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				MessageEntity message=new MessageEntity();
				if(ObjectUtils.isEmpty(messageType)){
					json.setMsg("消息类型不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				MessageTypeEntity messageT=messageTypeService.queryObject(messageType);
				if(ObjectUtils.isEmpty(messageT)){
					json.setMsg("没有找到对应的消息类型！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setMessageType(messageT.getMessageTypeName()+","+messageT.getDisplayMode()); //消息类型
				if(ObjectUtils.isEmpty(messageTag)){
					json.setMsg("消息标签不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setMessageTag(messageTag); //消息标签
				if(ObjectUtils.isEmpty(messageHeader)){
					json.setMsg("消息标题不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setMessageHeader(messageHeader); //消息标题
				if(ObjectUtils.isEmpty(messageProfile)){
					json.setMsg("消息简介不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setMessageProfile(messageProfile); //消息简介
			
				message.setMessageCoverUrl(messageCoverUrl); //消息封面url
				if(ObjectUtils.isEmpty(displayMode)){
					json.setMsg("展现方式不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setDisplayMode(displayMode); //展现方式
				if(!"跳转页面".equals(displayMode)&&!"直接打开".equals(displayMode)){
					json.setMsg("展现方式有误！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				if("跳转页面".equals(displayMode)){
					if(ObjectUtils.isEmpty(messageLink)){
						json.setMsg("消息链接不能为空！");
						json.setResult(false);
						ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
						return;
					}
					message.setMessageLink(messageLink); //消息链接
				}else{	
					if(ObjectUtils.isEmpty(messageContent)){
						json.setMsg("消息内容不能为空！");
						json.setResult(false);
						ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
						return;
					}
					message.setMessageContent(messageContent); //消息内容
				}
				if(ObjectUtils.isEmpty(receiveMessageObjectType)){
					json.setMsg("接收消息对象类型不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setReceiveMessageObjectType(receiveMessageObjectType); //接收消息对象类型
				if(!"定向".equals(receiveMessageObjectType)&&!"全员".equals(receiveMessageObjectType)){
					json.setMsg("接收消息对象类型有误！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				if("定向".equals(receiveMessageObjectType)){
					if(ObjectUtils.isEmpty(receiveMessageObjects)){
						json.setMsg("接收消息对象不能为空！");
						json.setResult(false);
						ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
						return;
					}
					message.setReceiveMessageObjects(receiveMessageObjects); //接收消息对象
				}
				if(ObjectUtils.isEmpty(ifPush)){
					json.setMsg("是否启用第三方推送不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setIfPush(ifPush);//是否启用第三方推送
				if(ifPush!=0&&ifPush!=1){
					json.setMsg("是否启用第三方推送信息有误！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				if(ifPush==1){
					if(ObjectUtils.isEmpty(whetherPush)){
						json.setMsg("推送方式不能为空！");
						json.setResult(false);
						ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
						return;
					}
					if(whetherPush!=0&&whetherPush!=1){
						json.setMsg("推送方式有误！");
						json.setResult(false);
						ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
						return;
					}
					message.setWhetherPush(whetherPush);//推送方式
					if(whetherPush==0){
						if(ObjectUtils.isEmpty(pushTime)){
							json.setMsg("推送时间不能为空！");
							json.setResult(false);
							ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
							return;
						}
//						DateUtil.dateLongToString(pushTime, "yyyy-MM-dd HH:mm:ss")
						message.setPushTime(
								DateUtil.stringToDate(
										DateUtil.dateLongToString(
												pushTime,  "yyyy-MM-dd HH:mm:ss")
										, "yyyy-MM-dd HH:mm:ss"));//推送时间
						
					}
				}
				
				if(ObjectUtils.isEmpty(displayTime)){
					json.setMsg("展示时间不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setDisplayTime(
								DateUtil.stringToDate(
										DateUtil.dateLongToString(
												displayTime,  "yyyy-MM-dd HH:mm:ss")
										, "yyyy-MM-dd HH:mm:ss")); //展示时间
				if(ObjectUtils.isEmpty(timeExpired)){
					json.setMsg("过期时间不能为空！");
					json.setResult(false);
					ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
					return;
				}
				message.setTimeExpired(
						DateUtil.stringToDate(
								DateUtil.dateLongToString(
										timeExpired,  "yyyy-MM-dd HH:mm:ss")
								, "yyyy-MM-dd HH:mm:ss")); //过期时间
				
				message.setChannelid(id);//渠道标识
				
				message.setMessageSource(MessageEntity.MESSAGE_SOURCE_TRANSFER); //消息来源
				message.setStatus(MessageEntity.ALREADY_RELEASED); //消息发布状态
				message.setPublishuser(id+"接口添加"); //发布人
				message.setPublishtime(DateUtil.getNowDateByServer()); //发布时间
				message.setCreateuser(id+"接口添加");
				
				
				messageService.save(message);
				
				json.setResult(true);
			}
		} catch (Exception e) {
			e.printStackTrace();
			json.setMsg("查询出错！");
			json.setResult(false);
		}
		ajaxJsonResponse(response,request,JsonUtil.beanToJson(json));
		return;
	}
	//推送到第三方
	@SuppressWarnings("unused")
	private void pushThirdParty(
			/**
			 * 调用应用id
			 */
			String appID,
			/**
			 * 消息主体
			 */
			MessageEntity message) {
		String url=appMessageService.queryObject(Integer.parseInt(appID)).getReceiveappmessage();
		String sr="";
		if("定向".equals(message.getReceiveMessageObjectType())){
			sr=HttpRequest.sendPost(url, 
					"messageHeader="+message.getMessageHeader()+"&"+//	消息标题	
					"messageProfile="+message.getMessageProfile()+"&"+//	消息简介	
					"receiveMessageObjectType="+message.getReceiveMessageObjectType()+"&"+//	接收消息对象类型	定向、全员
					"receiveMessageObjects="+message.getReceiveMessageObjects()+"&"+//	接收消息对象 接收消息对象类型是全员该字段非必填，接收消息对象类型是定向必填 传输内容 人员唯一标识用逗号隔开如 zhang,li,liu,wang,cheng
					"pushTime="+message.getPushTime().getTime()//	推送时间
							);
		}else{
			sr=HttpRequest.sendPost(url, 
					"messageHeader="+message.getMessageHeader()+"&"+//	消息标题	
					"messageProfile="+message.getMessageProfile()+"&"+//	消息简介	
					"receiveMessageObjectType="+message.getReceiveMessageObjectType()+"&"+//	接收消息对象类型	定向、全员
					"pushTime="+message.getPushTime().getTime()//	推送时间
							);
		}
		
        System.out.println(sr);

	}
	
	
	/**
	 * 信息校验
	 * @param sign
	 * @throws NoSuchAlgorithmException
	 * @throws UnsupportedEncodingException
	 */
	private boolean informationCheck(
			/**
			 * 传过来的加密串
			 */
			String sign,
			/**
			 * 调用应用id
			 */
			String appID,
			/**
			 * 需要校验的值
			 */
			String encryptionRequired
			) throws NoSuchAlgorithmException, UnsupportedEncodingException {
		String result = "";  
		
		String key=appMessageService.queryObject(Integer.parseInt(appID)).getKey();
		String str=encryptionRequired+key;
		MessageDigest md5 = MessageDigest.getInstance("MD5");  
		md5.update((str).getBytes("UTF-8"));  
		byte b[] = md5.digest();  
		  
		int i;  
		StringBuffer buf = new StringBuffer("");  
		  
		for(int offset=0; offset<b.length; offset++){  
		    i = b[offset];  
		    if(i<0){  
		        i+=256;  
		    }  
		    if(i<16){  
		        buf.append("0");  
		    }  
		    buf.append(Integer.toHexString(i));  
		}  
		  
		result = buf.toString();  
		System.out.println("需要校验的值 = " + encryptionRequired);
		
		System.out.println("调用应用id = " + appID);
		System.out.println("result = " + result);
		System.out.println("sign = " + sign);
		if(result.equals(sign)){
			return false; 
		}else{
			return true; 
		}

	}
	
	/**
	 * 未读消息计算
	 */
	private String unreadCount(
			/**应用id*/
			String id, 
			/** 用户唯一标识 */
			String userUniqueID,
			/**消息类型 */
			String messageType,
			/**用户创建时间 */
			String createTime) {
		
		//可见消息数量
		int messageShowCount=messageService.messageCount(
				this.findMap(id, userUniqueID, messageType,createTime));
		//已阅读阅读消息数量
		int messagesRecordCount=messageRecordService.messagesRecordCount(
				this.findMap(id, userUniqueID, messageType,createTime));
		
		int unreadMessage=messageShowCount-messagesRecordCount;
		return unreadMessage+"";
	}
	
	
	/**
	 * 查询条件拼接
	 * @param channelid
	 * @param receiveMessageObject
	 * @param messageType
	 * @return
	 */
	private Map<String, Object> findMap(
			/** 应用id */
			String channelid,
			/** 用户唯一标识 */
			String receiveMessageObject,
			/**消息类型 */
			String messageType,
			/**用户创建时间 */
			String time) {
		
		Date createTime=DateUtil.stringToDate(time, "yyyy-MM-dd HH:mm:ss");
		Map<String, Object> map = new HashMap<>();

		map.put("channelid",channelid);
		map.put("receiveMessageObject",receiveMessageObject);
		if(!ObjectUtils.isEmpty(messageType)){
			map.put("messageType",messageType);
		}
		if(!ObjectUtils.isEmpty(createTime)){
			map.put("createTime",createTime);
		}
		return map;

	}
	
	
	/**
	 * 获取消息类型列表
	 * @param id
	 */
	private List<MessageTypeEntity> messageTypeList(String id) {

		Map<String, Object> map = new HashMap<>();
		map.put("channelid", id);
		//查询列表数据
		List<MessageTypeEntity> messageTypeList = messageTypeService.queryList(map);
		return messageTypeList;

	}
	/**
	 * 接收前台传输参数
	 * */
	public class ReceivingSet implements Serializable{
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		/**用户唯一标识*/
		String userUniqueID;
		/**消息id*/
		String messageID;
		/**应用id*/
		String appID;
		/**用户创建时间*/
		long createTime;
		String sign;
		/**消息类型*/
		Integer mType;
		Integer page;
		Integer limit;
		public String getUserUniqueID() {
			return userUniqueID;
		}
		public void setUserUniqueID(String userUniqueID) {
			this.userUniqueID = userUniqueID;
		}
		public String getMessageID() {
			return messageID;
		}
		public void setMessageID(String messageID) {
			this.messageID = messageID;
		}
		public String getAppID() {
			return appID;
		}
		public void setAppID(String appID) {
			this.appID = appID;
		}
		public long getCreateTime() {
			return createTime;
		}
		public void setCreateTime(long createTime) {
			this.createTime = createTime;
		}
		public String getSign() {
			return sign;
		}
		public void setSign(String sign) {
			this.sign = sign;
		}
		public Integer getmType() {
			return mType;
		}
		public void setmType(Integer mType) {
			this.mType = mType;
		}
		public Integer getPage() {
			return page;
		}
		public void setPage(Integer page) {
			this.page = page;
		}
		public Integer getLimit() {
			return limit;
		}
		public void setLimit(Integer limit) {
			this.limit = limit;
		}
	}
	
	
	/**
	 * 消息中心列表字段
	*/
	
	public class MessageCenterClass implements Serializable {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		/**id*/
		private String id;
		/**icon地址*/
		private String iconUrl;
		/**类型名称*/
		private String messageTypeName;
		/**消息标签*/
		private String messageTag;
		/**消息标题*/
		private String messageHeader;
		/**消息简介*/
		private String messageProfile;
		/**未读消息数量*/
		private String unreadCount;
		/** 跳转页面url */
		private String typeUrl;
		public String getIconUrl() {
			return iconUrl;
		}
		public void setIconUrl(String iconUrl) {
			this.iconUrl = iconUrl;
		}
		public String getMessageTypeName() {
			return messageTypeName;
		}
		public void setMessageTypeName(String messageTypeName) {
			this.messageTypeName = messageTypeName;
		}
		public String getMessageTag() {
			return messageTag;
		}
		public void setMessageTag(String messageTag) {
			this.messageTag = messageTag;
		}
		public String getMessageHeader() {
			return messageHeader;
		}
		public void setMessageHeader(String messageHeader) {
			this.messageHeader = messageHeader;
		}
		public String getMessageProfile() {
			return messageProfile;
		}
		public void setMessageProfile(String messageProfile) {
			this.messageProfile = messageProfile;
		}
		public String getUnreadCount() {
			return unreadCount;
		}
		public void setUnreadCount(String unreadCount) {
			this.unreadCount = unreadCount;
		}
		public String getId() {
			return id;
		}
		public void setId(String id) {
			this.id = id;
		}
		public String getTypeUrl() {
			return typeUrl;
		}
		public void setTypeUrl(String typeUrl) {
			this.typeUrl = typeUrl;
		}

	}
}
